/**
 *
 * Copyright 2012 TeleNav, Inc. All rights reserved.
 * Edge.java
 *
 */
package com.telenav.snowsweeper.data;

/**
 *@author hhzhu
 *@date 2012-12-7
 */
public class Edge
{
	// to the right direction and down direction is positive, left top is origin point. 
    private String index = "";
    private int id = -1;    
    private int posTransTime/* = 0*/;  
    private int negTransTime/* = 0*/;
    
    private Point begin;
	public void setBegin(Point begin)
    {
        this.begin = begin;
    }

    private Point end;
    
    private int snowNum/* = 0*/;
    private int snowMaxNum/* = 0*/;
    private float snowRecoverRate/* = 0f*/;
    private long timeStamp/* = 0*/;
    private int minSurvivingTime = -1;

	public Edge(String index,int id, int posTransTime, int negTransTime, Point begin, Point end) {
    	this.index = index;
	    this.id = id;
    	this.posTransTime = posTransTime;
    	this.negTransTime = negTransTime;
    	this.begin = begin;
    	this.end = end;
    }

	public int[] getBeginIndex()
	{
	    if(this.begin != null)
	    {
	        int i[] = {begin.getX(),begin.getY()};
	        return i;
	    }
	    return null;
	}
    
    public int[] getEndIndex()
    {
        if (this.end != null)
        {
            int i[] = { end.getX(), end.getY() };
            return i;
        }
        return null;
    }
	    
	
	public void setEnd(Point end)
    {
        this.end = end;
    }

    public void serIndex(String index)
	{
	    this.index = index;
	}
	
    public boolean posDirectionAvailable() {
    	return posTransTime > 0;
    }
    
    public boolean negDirectionAvailable() {
    	return negTransTime > 0;
    }
    
    public int getPosTransTime() {
    	return posTransTime;
    }
    
    public int getNegTransTime() {
    	return negTransTime;
    }
    
    public int getSnowNum() {
		return snowNum;
	}

	public void setSnowNum(int snowNum) {
		this.snowNum = snowNum;
	}
	
	public int getSnowMaxNum() {
		return snowMaxNum;
	}

	public void setSnowMaxNum(int snowMaxNum) {
		this.snowMaxNum = snowMaxNum;
	}
	
	public float getSnowRecoverRate() {
		return snowRecoverRate;
	}

	public void setSnowRecoverRate(float snowRecoverRate) {
		this.snowRecoverRate = snowRecoverRate;
	}
	
	public String getIndex() {
		return index;
	}
	
    public int getMinSurvivingTime() {
		return minSurvivingTime;
	}

	public void setMinSurvivingTime(int minSurvivingTime) {
		this.minSurvivingTime = minSurvivingTime;
	}
	
    public Point getBegin() {
		return begin;
	}

	public Point getEnd() {
		return end;
	}
	
	public void getMiddleOnScreen(int[] out_xy, long timeStamp) {
		int[] b = begin.getScreenXY(timeStamp);
		int[] e = end.getScreenXY(timeStamp);
		if (b != null && e != null) {
			out_xy[0] = b[0] + e[0] >> 1;
			out_xy[1] = b[1] + e[1] >> 1; 
		}
	}
}